<template>
  <view class="custom-segment">
    <view v-for="(item, index) in items" :key="index" class="segment-item" :class="{ active: current === index }" @click="switchSegment(index)">
      <view class="value">{{ item }}</view>
      <view class="line" :class="{ active: current === index }"></view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    items: {
      type: Array,
      default: [],
    },
    current: {
      type: Number,
      default: 0,
    },
  
  },
  data() {
    return {}
  },
  methods: {
    switchSegment(index) {
      this.$emit('changeTab', { currentIndex: index })

    },
  },
}
</script>

<style>
.custom-segment {
  display: flex;
  /* height: 80rpx;
  line-height: 80rpx; */
  text-align: center;
}

.segment-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: all 0.3s;
  color: white;
  font-size: 32rpx;
  margin-top: 30rpx;
}
.value{
  margin-bottom: 15rpx;
}

.segment-item.active {
  color: white;
  font-weight: bold;
}
.line.active {
  width: 30rpx;
  height: 6rpx;

  border-radius: 50rpx;
  background:white;
  margin: 5rpx auto 0 auto;
}
</style>
